package com.regent.central.bill.service.bean.mrp.util;

import java.time.LocalDate;

/**
 * mrp模块单据号生成工具
 *
 * @author 钟宝林
 * @date 2018-06-19 19:40
 **/
public final class MrpOrderNoGenerateUtil {

    public static String generate(int billCount, String prefix) {
        int count = billCount + 1;
        LocalDate now = LocalDate.now();
        String yearStr = now.getYear() + "";
        String year = yearStr.substring(2);
        String monthStr = now.getMonthValue() + "";
        String month = monthStr.length() <= 1 ? "0" + monthStr : monthStr;
        String dayOfMonthStr = now.getDayOfMonth() + "";
        String dayOfMonth = dayOfMonthStr.length() <= 1 ? "0" + dayOfMonthStr : dayOfMonthStr;

        String purchaseCount = count < 10 ? "00" + count : (count < 100 ? "0" + count : count + "");
        return prefix + year + month + dayOfMonth + purchaseCount;
    }

}
